import 'package:enjoy_plus/models/repair_model.dart';
import 'package:flutter/foundation.dart';

class RepairProvider with ChangeNotifier {
  // 问题附件
  List<ImageAttachment> _imageUrlList = [];
  // 报修房屋
  String _selectedHouse = '';
  // 报修项目
  String _selectedRepair = '';
  // 报修人电话
  String _phoneNumber = '';
  // 报修日期
  String _selectedDate = '';
  // 问题描述
  String _problemDescription = '';

  // getters
  List<ImageAttachment> get imageUrlList => _imageUrlList;
  String get selectedHouse => _selectedHouse;
  String get selectedRepair => _selectedRepair;
  String get phoneNumber => _phoneNumber;
  String get selectedDate => _selectedDate;
  String get problemDescription => _problemDescription;

  // setters
  void setImageUrlList(ImageAttachment imageUrl) {
    _imageUrlList.add(imageUrl);
    notifyListeners();
  }
  void removeImageUrlList(ImageAttachment imageUrl) {
    _imageUrlList.remove(imageUrl);
    notifyListeners();
  }

  void setSelectedHouse(String house) {
    _selectedHouse = house;
    notifyListeners();
  }

  void setSelectedRepair(String repair) {
    _selectedRepair = repair;
    notifyListeners();
  }

  void setSelectedDate(String date) {
    _selectedDate = date;
    notifyListeners();
  }

  void setProblemDescription(String description) {
    _problemDescription = description;
    notifyListeners();
  }

  void setPhoneNumber(String phone) {
    _phoneNumber = phone;
    notifyListeners();
  }

  void clear() {
    _imageUrlList.clear();
    _selectedHouse = '';
    _selectedRepair = '';
    _selectedDate = '';
    _problemDescription = '';
    _phoneNumber = '';
  }
}
